package org.jash.day7;

import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import org.jash.day7.entity.DataBean;
import org.jash.day7.mvp.BaseFragment;
import org.jash.day7.utils.ConStruct;

import java.util.List;


public class BlankFragment extends BaseFragment<ConStruct.IBlankView, BlankPresenter> implements ConStruct.IBlankView {
    private NewsAdapter adapter = new NewsAdapter();
    private RecyclerView recycler;
    private Handler handler = new Handler(Looper.getMainLooper());
    @Override
    protected int layoutId() {
        return R.layout.fragment_blank;
    }

    @Override
    protected void initData() {
        presenter = new BlankPresenter();
        handler.postDelayed(() -> presenter.loadTopHot(), 100);
    }

    @Override
    protected void initView() {
        recycler = getView().findViewById(R.id.recycler);
        recycler.setAdapter(adapter);
    }

    @Override
    public void success(List<DataBean> list) {
        Log.d("TAG", "success: " + list);
        adapter.addAll(list);
    }

    @Override
    public void failure(Throwable t) {

    }
}